import 'package:enterprise_v6_app/app/components/custom_app_bar.dart';
import 'package:enterprise_v6_app/app/core/values/dimens.dart';
import 'package:enterprise_v6_app/app/core/values/gaps.dart';
import 'package:enterprise_v6_app/app/core/values/images.dart';
import 'package:enterprise_v6_app/app/modules/application/education/demand_research/findings/findings_controller.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_svg/svg.dart';
import 'package:get/get.dart';

class FindingsPage extends StatelessWidget {
  FindingsPage({super.key});

  final controller = Get.put(FindingsController());

  @override
  Widget build(BuildContext context) {
    return GetBuilder(
        init: controller,
        builder: (_) {
          return Scaffold(
            appBar: CustomAppBar(
              title: Text(
                '调研结果',
                style: TextStyle(
                  fontSize: 18.sp,
                  color: Colors.white,
                  fontWeight: FontWeight.w400,
                ),
              ),
              leading: const BackButton(
                color: Colors.white,
              ),
              iconButtonColor: Colors.white,
              backgroundColor: const Color(0xFF5C6DFF),
            ),
            body: Container(
                color: const Color(0xFFF5F5F6),
                child: Stack(
                  children: [
                    //基础信息
                    _getBasicInformation(),
                    Container(
                      margin: EdgeInsets.only(top: 50.w),
                      padding: EdgeInsets.symmetric(horizontal: 16.w),
                      child: Column(
                        children: [
                          _getDetailsView(),
                          _divider(),
                          Expanded(child: _geBottomView()),
                          AppGaps.vGap20,
                        ],
                      ),
                    )
                  ],
                )),
          );
        });
  }

  Widget _getBasicInformation() {
    return Container(
      height: 150.w,
      width: AppDimens.sh,
      padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 16.w),
      color: const Color(0xFF5C6DFF),
      child: Column(
        children: [
          Row(
            children: [
              SvgPicture.asset(
                AppImages.icon_finding,
                width: 17.w,
                height: 17.w,
              ),
              AppGaps.hGap6,
              Expanded(
                  child: Text(
                '恭喜你、完成调研！',
                style: TextStyle(
                  fontSize: 16.sp,
                  color: Colors.white,
                  overflow: TextOverflow.ellipsis,
                  fontWeight: FontWeight.w500,
                ),
              )),
            ],
          ),
        ],
      ),
    );
  }

  Widget _getDetailsView() {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 20.w),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.only(
          topRight: Radius.circular(6.w),
          topLeft: Radius.circular(6.w),
        ),
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.start,
            children: [
              // Container(
              //   color: Colors.red,
              //   width: 13.94.w,
              //   height: 13.94.w,
              // ),
              SvgPicture.asset(
                AppImages.icon_findings_result_select,
              ),
              AppGaps.hGap6,
              Text(
                '已选择专题',
                style: TextStyle(
                  fontSize: 16.sp,
                  color: const Color(0xFF262F38),
                  overflow: TextOverflow.ellipsis,
                  fontWeight: FontWeight.w400,
                ),
              ),
            ],
          ),
          AppGaps.vGap6,
          // Row(
          //   children: controller.list
          //       .map(
          //         (e) => Text(
          //           e,
          //           style: TextStyle(
          //             fontSize: 14.sp,
          //             color: const Color(0xFF495061),
          //             overflow: TextOverflow.ellipsis,
          //             fontWeight: FontWeight.w400,
          //           ),
          //         ),
          //       )
          //       .toList(),
          // ),
          Wrap(
            // spacing: 47.w, // 主轴(水平)方向间距
            // runSpacing: 12.w, // 纵轴（垂直）方向间距
            children: controller.list
                .map(
                  (e) => Text(
                    e,
                    style: TextStyle(
                      fontSize: 14.sp,
                      color: const Color(0xFF495061),
                      overflow: TextOverflow.ellipsis,
                      fontWeight: FontWeight.w400,
                    ),
                  ),
                )
                .toList(),
          )
        ],
      ),
    );
  }

  Widget _geBottomView() {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 15.w),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.only(
          bottomRight: Radius.circular(6.w),
          bottomLeft: Radius.circular(6.w),
        ),
      ),
      child: Column(
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.start,
            children: [
              SvgPicture.asset(
                AppImages.icon_findings_recommendation,
              ),
              AppGaps.hGap6,
              Text(
                '建议',
                style: TextStyle(
                  fontSize: 16.sp,
                  color: const Color(0xFF262F38),
                  overflow: TextOverflow.ellipsis,
                  fontWeight: FontWeight.w400,
                ),
              ),
            ],
          ),
          AppGaps.vGap6,
          Expanded(
            child: Align(
              alignment: Alignment.topLeft,
              child: Text(
                '${controller.recommendation}',
                style: TextStyle(
                  fontSize: 14.sp,
                  color: const Color(0xFF262F38),
                  fontWeight: FontWeight.w400,
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }

  ///分割线
  Widget _divider() {
    return Container(
      height: 0.5.w,
      decoration: const BoxDecoration(
          gradient: LinearGradient(begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [
        Color(0x33587DF5),
        Color(0x33587DF5),
        Color(0x33587DF5),
      ])),
    );
  }
}
